<template>
  <div id="app">
    <el-config-provider :locale="locale">
      <router-view></router-view>
    </el-config-provider>
  </div>
</template>

<script setup>
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import en from 'element-plus/es/locale/lang/en'
import {closeWorker, initWorker} from "@/utils/message";
import {tokenApi} from "@/api/user"
import {setToken} from "@/utils/auth"

const language = ref('zh-cn')
const locale = computed(() => (language.value === 'zh-cn' ? zhCn : en))

onMounted(() => {
  tokenApi().then((res) => {
    setToken(res.data.token)
    initWorker(res.data.token);
  })
})

onBeforeUnmount(() => {
  closeWorker()
})
</script>

<style>
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
  width: 100%;
}
</style>
